#ifndef AUBOROBOT_H
#define AUBOROBOT_H

#include <QObject>
#include "device.h"
#include "AuboRobotMetaType.h"
#include "rsdef.h"
#include "rserrors.h"
#include "rspidcfg.h"
#include "rstype.h"

class AuboRobot : public Device
{
    Q_OBJECT
public:
    explicit AuboRobot(QObject *parent = nullptr);

    QString strIP() const;
    void setStrIP(const QString &newStrIP);
    int nPort() const;
    void setNPort(int newNPort);
    float               GetVelocity(){return m_dblVelocity;}
    float               GetAcceleration(){return m_dblAcceleration;}
    void                SetVelocity(double value);
    void                SetAcceleration(double value);

private:
    RSHD                m_rshd;
    double              m_dblJointRadian[ARM_DOF];
    QString             m_strIP;
    int                 m_nPort;
    //                  后增加的
    double               m_dblVelocity; // 机械臂的运行速度
    double               m_dblAcceleration; // 机械臂的加速度

    bool isInPos(double* dest_pos,double* cur_pos,double theshold);

signals:
    void strIPChanged();
    void nPortChanged();

public:
    virtual void writeXML(QXmlStreamWriter &writer) override;
    virtual void readFromXML(QXmlStreamReader &reader) override;

    virtual int initDevice() override;
    virtual void writeData(const QVariant &data) override;
    virtual void uninitDevice() override;

    virtual QString getClassName() override;


public:
    Q_PROPERTY(QString strIP READ strIP WRITE setStrIP NOTIFY strIPChanged FINAL)
    Q_PROPERTY(int nPort READ nPort WRITE setNPort NOTIFY nPortChanged FINAL)
};

#endif // AUBOROBOT_H
